﻿using System;

namespace IceCS.MovieRent
{

    public class Movie
    {
        public string Title { get; private set; }

        public Price Price { get; set; }

        public Movie(string title, Price price)
        {
            Title = title;
            Price = price;
        }

        public void SetPriceCode(PriceCode priceCode)
        {
            switch (priceCode)
            {
                case PriceCode.REGULAR:
                    Price = new RegularPrice();
                    break;
                case PriceCode.CHILDRENS:
                    Price = new ChildrenPrice();
                    break;
                case PriceCode.NEW_RELEASE:
                    Price = new NewReleasePrice();
                    break;
                default:
                    throw new ArgumentException("Incorrect Price Code");
            }
        }

        public double GetCharge(int daysRented)
        {
            return Price.GetCharge(daysRented);
        }

        public int GetFrequentRenterPoints(int daysRented)
        {
            return (Price.PriceCode == PriceCode.NEW_RELEASE) && daysRented > 1 ? 2 : 1;
        }
    }

}
